package com.lin.zoo.view;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;

public class MasterPage extends JPanel{

    private JButton rePark=new JButton("管理园区信息");
    //管理园区信息
    private JButton reFeeder=new JButton("管理动物饲养员");
    //管理动物饲养员
    private JButton indent=new JButton("管理退票");

    public JButton getIndent() {
        return indent;
    }

    public void setIndent(JButton indent) {
        this.indent = indent;
    }

    public JButton getReFeeder() {return reFeeder;}

    public void setReFeeder(JButton reFeeder) {this.reFeeder = reFeeder;}

    public JButton getRePark() {return rePark;}

    public void setRePark(JButton rePark) {this.rePark = rePark;}

    public void createAndShowGUI() {

        JFrame frame = new JFrame("园长界面");
        frame.setVisible(true);
        frame.setSize(700,530);

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        // 显示窗口
        frame.setResizable(false);
        //固定窗口大小不被修改
        frame.setLocationRelativeTo(null);
        //窗口处于中央

        init();
        frame.setLayout(null);
        frame.add(rePark);
        frame.add(reFeeder);
        frame.add(indent);

        getRePark().addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ParkMasterPage masterPage=new ParkMasterPage();
                try {
                    masterPage.createAndShowGUI();
                } catch (SQLException ex) {
                    System.out.println("数据修改错误" + this.getClass().getName());
                }
            }
        });

        getReFeeder().addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                FeederMasterPage feederMasterPage=new FeederMasterPage();
                try {
                    feederMasterPage.createAndShowGUI();
                } catch (SQLException ex) {
                    System.out.println("数据修改错误" + this.getClass().getName());
                }
            }
        });
        //退票管理系统
        getIndent().addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                IndentMasterPage indentMasterPage=new IndentMasterPage();
                try {
                    indentMasterPage.creatAndShowGUI();
                } catch (SQLException ex) {
                    System.out.println("退票确认失败" + this.getClass().getName());
                }
            }
        });

    }



    private void init(){
        //需要700*500的空间
        rePark.setSize(200,100);
        rePark.setLocation(100,100);

        reFeeder.setSize(200,100);
        reFeeder.setLocation(400,100);

        indent.setSize(200,100);
        indent.setLocation(100,300);
    }

}
